import {
  getMenuByUserName
} from '../../api/yun/user/index'
const permission = {
  state: {
    addRouters: [],
    resources: [],
    menuList: []
  },
  mutations: {
    SET_ROUTERS: (state, routers) => {
      state.addRouters = routers
    },
    SET_RESOURCES: (state, resources) => {
      state.resources = resources
    },
    SET_MENU_LIST: (state, menuList) => {
      state.menuList = menuList
    }
  },
  actions: {
    getMenuByUserName ({ commit }) {
      return new Promise((resolve, reject) => {
        getMenuByUserName().then(response => {
          resolve(response)// 将response的值返回
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default permission
